package com.yh.workbill.network;

import com.yh.workbill.model.Company;
import com.yh.workbill.model.Count;
import com.yh.workbill.model.LoginSuccess;
import com.yh.workbill.model.ResponseMsg;
import com.yh.workbill.model.UseCompany;
import com.yh.workbill.model.WorkBill;
import com.yh.workbill.model.WorkBillCount;
import com.yh.workbill.model.WorkDevices;
import com.yh.workbill.utils.Config;

import java.util.List;

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface ApiService {


    @POST(Config.LOGIN)
    @FormUrlEncoded
    Call<ResponseMsg<LoginSuccess>> login(@Field("phone") String phone, @Field("password") String password);


    @GET(Config.CHECKTOKEN)
    Call<ResponseMsg<String>> checkToken(@Header("Authorization") String authorization);

    @GET(Config.GETALLCOMPANY)
    Call<ResponseMsg<List<Company>>> allCompany(@Query("user_uuid") String user_uuid, @Query("pageindex") int pageindex, @Query("pagenumber") int pagenumber);

    @GET(Config.GETALLUNITCOMPANY)
    Call<ResponseMsg<List<UseCompany>>> allUnitCompany(@Query("user_uuid") String user_uuid, @Query("pageindex") int pageindex, @Query("pagenumber") int pagenumber);

    @GET(Config.GETWORKBILL)
    Call<ResponseMsg<List<WorkBill>>> workbills(@Query("user_uuid") String user_uuid, @Query("pageindex") int pageindex, @Query("pagenumber") int pagenumber);

    @POST(Config.ADDWORKBILL)
    @FormUrlEncoded
    Call<ResponseMsg<String>> AddWorkBill(
            @Field("user_uuid") String user_uuid,
            @Field("work_time") String work_time,
            @Field("work_unit") String work_unit,
            @Field("work_content") String work_content,
            @Field("work_car_number") String work_car_number,
            @Field("work_device") String work_device,
            @Field("work_use_time") double work_use_time,
            @Field("company_name") String company_name,
            @Field("work_time_price") double work_time_price
    );

    @GET(Config.DEVICES)
    Call<ResponseMsg<List<WorkDevices>>> getDevices();

    @POST(Config.UPDATAWORKBILL)
    @FormUrlEncoded
    Call<ResponseMsg<String>> UpdataWorkBill(
            @Field("uuid") String uuid,
            @Field("user_uuid") String user_uuid,
            @Field("work_time") String work_time,
            @Field("work_unit") String work_unit,
            @Field("work_content") String work_content,
            @Field("work_car_number") String work_car_number,
            @Field("work_device") String work_device,
            @Field("work_use_time") double work_use_time,
            @Field("company") String company_name,
            @Field("work_time_price") double work_time_price
    );

    @GET(Config.DELWORKBILL)
    Call<ResponseMsg<String>> delWorkBill(@Query("uuid") String uuid, @Query("user_uuid") String user_uuid);

    @GET(Config.COUNTBILLS)
    Call<ResponseMsg<List<Count>>> getCounts(@Query("user_uuid") String user_uuid,
                                             @Query("pageindex") int pageindex,
                                             @Query("pagenumber") int pagenumber);

    @GET(Config.WORKBILLCOUNT)
    Call<ResponseMsg<WorkBillCount>> getWorkBillCount(@Query("user_uuid") String user_uuid);


    @POST(Config.ADDCOMPANYNAME)
    @FormUrlEncoded
    Call<ResponseMsg<String>> addCompanyName(
            @Field("user_uuid") String user_uuid,
            @Field("company_name") String company_name,
            @Field("company_address") String company_address,
            @Field("company_phone") String company_phone
    );

    @POST(Config.ADDUNITCOMPANYNAME)
    @FormUrlEncoded
    Call<ResponseMsg<String>> addUnitCompanyName(
            @Field("user_uuid") String user_uuid,
            @Field("work_use_company") String work_use_company);

    @GET(Config.SEARCH)
    Call<ResponseMsg<List<WorkBill>>> getSearch(
            @Query("user_uuid") String user_uuid,
            @Query("companyname") String companyname,
            @Query("year") String year,
            @Query("month") String month,
            @Query("pageindex") int pageindex,
            @Query("pagenumber") int pagenumber
    );


    @GET(Config.COUNTINFO)
    Call<ResponseMsg<List<WorkBill>>> getCountInfo(
            @Query("user_uuid") String user_uuid,
            @Query("companyname") String companyname,
            @Query("unitname") String unitname,
            @Query("year") String year,
            @Query("month") String month,
            @Query("pageindex") int pageindex,
            @Query("pagenumber") int pagenumber
    );

    @POST(Config.EXCELFILE)
    @FormUrlEncoded
    Call<ResponseMsg<String>> postExcelFile(
            @Field("user_uuid") String user_uuid,
            @Field("phone") String phone,
            @Field("ids") String json,
            @Field("year") String year,
            @Field("month") String month,
            @Field("companyname") String companyname,
            @Field("unitname") String unitname,
            @Field("pageindex") int pageindex,
            @Field("pagenumber") int pagenumber
    );

    @POST(Config.DELCOMPANY)
    @FormUrlEncoded
    Call<ResponseMsg<String>> postDelCompany(
            @Field("user_uuid") String user_uuid,
            @Field("uuid") String uuid
    );

    @POST(Config.DELUSECOMPANY)
    @FormUrlEncoded
    Call<ResponseMsg<String>> postDelUseCompany(
            @Field("user_uuid") String user_uuid,
            @Field("uuid") String uuid
    );

}
